package com.nxn.core.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.nxn.core.utils.Page;

/**
 * Entity Manager that talks to EntityDao to CRUD POJOs.
 * 
 * <p>
 * Extend this interface if you want typesafe (no casting necessary) managers
 * for your domain objects.
 * 
 * @author Michael
 * @param <T>
 *            a type variable
 * @param <PK>
 *            the primary key for that type
 */
public interface GenericManager<T, PK extends Serializable> {

	public T get(Class<T> entityClass, PK id);

	public List<T> getAll(Class<T> entityClass);
	
	public Page<T> queryPage(final Page<T> page, final String hql, final Object... values);
	
	public Page<T> queryPage(final Page<T> page, final String hql, final Map<String, ?> values);

	public boolean exists(Class<T> entityClass, PK id);
	
	public T save(T entity);
	
	public void remove(T entity);

}
